<template>
  <div class="top_bar">
    <div class="banner_area" v-if="dataSourse.length > 0">
      <van-swipe class="img" :autoplay="3000">
        <van-swipe-item v-for="(item, index) in dataSourse" :key="index">
          <span class="swipe_img">
            <img :src="item.pictureUrl" @click="go(item)" />
          </span>
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="tab_area" v-if="options.length > 0">
      <van-tabs type="card" v-model="activeSortTab">
        <van-tab class="tab" v-for="(item, index) of options" :key="index">
          <div slot="title">
              <div class="text" @click="changeSortTab(item, index)">
                <div class="font13">{{ item.name }}</div>
                <div class="font11">{{ item.remark }}</div>
              </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
    <!-- <ul class="tab-bar">
      <li class='tab-item' :class="[item.value == value ? 'active1' : '']" v-for="(item,index) of tabList" :key="index" @click="changeTab(item,index)">
        {{getLabel(item)}}
        <div :class="[item.value == value ? 'active' : '']"></div>
      </li>
    </ul> -->
    <div class="search_area">
      <div class="searchTape">
        <van-dropdown-menu>
          <van-dropdown-item
            v-model="titleTabActive"
            :options="cateLabelList"
            @change="selectTab"
          />
        </van-dropdown-menu>
      </div>
      <div class="divtip">
        <input type="text" v-model="keyWord" placeholder="搜索厂家/品名" />
        <div class="div" @click="search">搜索</div>
      </div>
    </div>
    <div></div>
  </div>
</template>
<script>
export default {
  props: {
    dataSourse: {},
    value: {},
    // num: '',
    showBanner: true,
  },
  data() {
    return {
      keyWord: "",
      titleTabActive: 0,
      activeSortTab: 0,
      showPopover: false,
      tabList: [
        { label: "全部", value: 0 },
        { label: "未加购", value: 2 },
        { label: "已加购", value: 1 },
      ],
      actions: [{ text: "选项一" }, { text: "选项二" }, { text: "选项三" }],
      cateLabelList: [
        { text: "全部", value: 0 },
        { text: "未加购", value: 2 },
        { text: "已加购", value: 1 },
      ],
      options: [],
    };
  },
  created() {
  },
  mounted() {},
  methods: {
    go(item) {
      if (item.type == 3) return;
      if (item.link == "") return;
      if (item.type == 2) {
        return window.open(item.link, "_blank");
      }
      let dataRouter = that.$router.resolve({
        path: item.link,
        query: item.parameter,
      });
      window.open(dataRouter.href, "_blank");
    },
    changeSortTab(item, index) {
      this.keyWord = "";
      this.activeSortTab = index;
      this.$emit("changeSortTab", item);
    },
    //下拉选择
    selectTab(value) {
      this.searchTape = value;
      this.$emit("changeTab", value);
    },
    getLabel(item) {
      let num;
      if (this.num) {
        num = this.num;
      } else {
        num = 0;
      }
      if (item.label == "已加购") {
        return item.label;
        // + '(' + num + ')'
      } else {
        return item.label;
      }
    },
    changeTab(item, index) {
      this.$emit("input", item.value);
      this.$emit("changeTab", item.value, item, index);
    },
    search() {
      this.$emit("search", this.keyWord);
    },
  },
};
</script>
<style lang="less" scoped>
.searchTape {
  margin-right: 20px;
}

.searchTape /deep/ .van-dropdown-menu__bar {
  width: 136px;
  height: 0.8rem;
  line-height: 0.8rem;
  background: #db281e;
  border-radius: 32px;
  color: #fff;
  border: 1px solid #f2948f;
}
.searchTape /deep/ .van-dropdown-menu__title--active {
  color: #fff;
}
.searchTape /deep/ .van-dropdown-menu__title {
  color: #fff;
  font-size: 0.32rem;
  display: inline-block;
  vertical-align: middle;
  height: 0.34rem;
  line-height: 0.34rem;
}

.searchTape /deep/ .van-dropdown-item__content {
  width: 1.8rem;
  top: 10px;
  left: 0.333333rem;
  border-radius: 20px;
}

.searchTape /deep/ .van-dropdown-item__option {
  height: 60px;
  line-height: 45px;
  font-size: 0.32rem;
}
.searchTape /deep/ .van-overlay {
  display: none;
}
.searchTape /deep/ .van-dropdown-menu__title::after {
  position: absolute;
  top: 40%;
  right: -0.18333rem;
  margin-top: -0.066667rem;
  border: 0.0699rem solid;
  border-color: transparent transparent #fff #fff;
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
  opacity: 0.8;
  content: "";
}
.top_bar {
  font-size: 0;
  .search_area {
    padding: 26px 24px;
    z-index: 999;
    height: 72px;
    display: flex;
    align-items: center;
    background-color: #e83d33;

    .divtip {
      display: flex;
      border-radius: 37px;
      opacity: 1;
      height: 0.8rem;
      background: #db291e;
      border: 1px solid rgba(255, 255, 255, 0.6);
      border-right: 0;
      color: #fff;
      border-radius: 38px;
      input {
        border-radius: 37px;
        flex: 1;
        height: 0.8rem;
        width: 4.4rem;
        line-height: 0.8rem;
        opacity: 1;
        color: #fff !important;
        border: none;
        padding: 0 30px;
        background-color: #db291e;
        letter-spacing: -1px;
        font-size: 26px;
        font-family: Microsoft YaHei, Microsoft YaHei-Regular;
        font-weight: 400;
        text-align: LEFT;
      }
      input::-webkit-input-placeholder {
        color: #fff;
      }

      .div {
        text-align: center;
        opacity: 1;
        width: 120px;
        height: 0.8rem;
        line-height: 0.8rem;
        width: 146px;
        margin-top: -1px;
        background: #db291e;
        border-radius: 36px;
        font-size: 26px;
        border: 1px solid rgba(255, 255, 255, 0.6);
        font-family: Microsoft YaHei, Microsoft YaHei-Regular;
        font-weight: 400;
        text-align: CENTER;
        color: #ffffff;
      }
    }
  }
  .tab_area {
    position: relative;
    width: 100%;
    .text {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 75px;
      div {
        line-height: 0.4rem;
      }
    }
    /deep/ .van-tabs__content {
      visibility: hidden;
    }
    /deep/ .van-tabs--card {
      height: 76px;
      width: 100%;
    }
    /deep/ .van-tab__text {
      display: inline-block;
      width: 100%;
    }
    /deep/ .van-tabs__wrap {
      height: 76px;
      width: 100%;
    }
    /deep/ .van-tabs__nav--card {
      height: 76px;
      background: #cc1b10 !important;
      justify-content: left;
      margin: 0;
      width: 100%;
    }
    /deep/ .van-tab {
      box-sizing: border-box;
      width: 20%;
      height: 75px;
      font-size: 0.313333rem;
      font-family: Microsoft YaHei, Microsoft YaHei-Regular;
      font-weight: 600;
      text-align: CENTER;
      color: #ffd9d9;
      border-right: 0.013333rem solid #ee0a24 !important;
      flex: none !important;
    }
    /deep/ .van-tab:nth-child(5) {
      border-right: 0 !important;
    }
    /deep/ .van-tab--active {
      box-sizing: border-box;
      width: 20%;
      height: 100%;
      // border-right: 1px solid #cc1b10;
      font-size: 0.313333rem;
      font-family: Microsoft YaHei, Microsoft YaHei-Regular;
      font-weight: 600;
      text-align: CENTER;
      color: #333333;
      flex: none !important;
      background: #ffffff;
    }
  }
  .banner_area {
    display: inline-block;
    opacity: 1;
    height: 340px;
    width: 100%;
    position: relative;
    z-index: 1;
    .img {
      // display: inline-block;
      background: #1e005a;
      width: 100%;
      height: 100%;
      .swipe_img {
        display: inline-block;
        width: 100%;
        height: 100%;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }

  .time_area {
    // background: #fff;
    // position: fixed;
    left: 0;
    right: 0;
    top: 340px;
    z-index: 999;
    // height: 90px;
  }

  .time_block {
    width: auto;
    height: 55px;
    line-height: 55px;
    opacity: 1;
    background: linear-gradient(180deg, #ff8d1e, #ff540d);
    border-radius: 4px;
    margin: 15px 24px 0 24px;
    box-sizing: border-box;

    .text {
      height: 50px;
      opacity: 1;
      font-size: 30px;
      font-family: PingFang, PingFang-Medium;
      font-weight: 500;
      text-align: justify;
      color: #ffffff;
      padding-left: 24px;
      line-height: 50px;
    }

    .num {
      padding: 0 4px;
      text-align: center;
      display: inline-block;
      width: auto;
      height: 36px;
      line-height: 36px;
      opacity: 1;
      background: #ffffff;
      border-radius: 8px;
      margin: 0 10px;
      color: #ff540d;
    }
  }
  .tab-bar {
    width: 100%;
    display: flex;
    height: 80px;
    line-height: 80px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    .tab-item {
      position: relative;
      width: calc(100% / 3.33);
      height: 100%;
      text-align: center;
      font-size: 32px;
      font-family: PingFang, PingFang-Regular;
      font-weight: 400;
      text-align: center;
      color: #ffffff;
      &.active1 {
        color: #ffbb0e;
      }
      .active {
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translate(-50%, 0);
        height: 4px;
        background: #ffbb0e;
        width: 30px;
      }
    }
  }
}
.tab_area /deep/ .van-tabs__nav--complete {
  padding-left: 0;
  padding-right: 0;
}
.font13 {
  font-size: 0.313333rem;
  font-weight: 600;
}
.font11 {
  font-weight: 400;
  font-size: 0.24rem;
  transform: scale(0.9);
  width: 2.5rem;
}
</style>